//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.ScientificWorkflow.SecurityControls
{
    using Microsoft.Research.DataLayer;

    /// <summary>
    /// 
    /// </summary>
    public class SecurityPolicyModel
    {
        /// <summary>
        /// Gets or sets the display name.
        /// </summary>
        /// <value>The display name.</value>
        public string DisplayName { get; set; }

        /// <summary>
        /// Gets or sets the security principal.
        /// </summary>
        /// <value>The security principal.</value>
        public ISecurityPrincipal SecurityPrincipal { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is builtin.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is builtin; otherwise, <c>false</c>.
        /// </value>
        public bool IsBuiltin { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityPolicyModel"/> class.
        /// </summary>
        /// <param name="SecurityPrincipal">The security principal.</param>
        public SecurityPolicyModel(ISecurityPrincipal SecurityPrincipal)
        {
            this.SecurityPrincipal = SecurityPrincipal;
            this.DisplayName = (SecurityPrincipal as INamedObject).Name;

            if (SecurityPrincipal is Group)
            {
                this.IsBuiltin = (SecurityPrincipal as Group).IsBuiltin;
            }
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            return this.DisplayName;
        }
    }
}
